#include "widget.h"
#include "ui_widget.h"
#include <QFileDialog>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    //弹出对话框，选择文件并获取文件信息
    QString path = QFileDialog::getOpenFileName(this);
    //构造QFileInfo对象
    QFileInfo fileinfo(path);
    ui->textEdit->append("文件名: " + fileinfo.fileName());
    ui->textEdit->append("文件后缀: " + fileinfo.suffix());
    ui->textEdit->append("文件路径: " + fileinfo.path());
    ui->textEdit->append("文件大小: " + QString::number(fileinfo.size()));
    ui->textEdit->append("文件类型是否是普通文件: " + QString(fileinfo.isFile() == true ? "是" : "不是"));
    ui->textEdit->append("文件类似是否是一个目录: " + QString(fileinfo.isDir() == true ? "是" : "不是"));
}
